Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: Files

Previous | Chapter Top | Chapter Contents | Next |

Opening Files

You can use the StandardGetFile procedure to present the standard user interface when the user asks to open a file. If you need to add elements to the default dialog boxes or exercise greater control over user actions in the dialog box, use CustomGetFile .

If your application is designed to execute in system software versions earlier than version 7.0, you can use the corresponding procedures SFGetFile and SFPGetFile .

StandardGetFile

You can use the StandardGetFile procedure to display the default Open dialog box when the user is opening a file.

PROCEDURE StandardGetFile (fileFilter: FileFilterProcPtr;
                                         numTypes: Integer;
                                         typeList: SFTypeList;
                                         VAR reply: StandardFileReply);
fileFilter
A pointer to an optional file filter function, provided by your application, through which StandardGetFile passes files of the specified types.
numTypes
The number of file types to be displayed. If you specify a numTypes value of -1, the first filtering passes files of all types.
typeList
A list of file types to be displayed.
reply
The reply record, which StandardGetFile fills in before returning.

DESCRIPTION

The StandardGetFile procedure presents a dialog box through which the user specifies the name and location of a file to be opened. While the dialog box is active, StandardGetFile gets and handles events until the user completes the interaction, either by selecting a file to open or by canceling the operation. StandardGetFile returns the user's input in a record of type StandardFileReply .

The fileFilter , numTypes , and typeList parameters together determine which files appear in the displayed list. The first filtering is by file type, which you specify in the numTypes and typeList parameters. The numTypes parameter specifies the number of file types to be displayed. You can specify one or more types. If you specify a numTypes value of -1, the first filtering passes files of all types.

The fileFilter parameter points to an optional file filter function, provided by your application, through which StandardGetFile passes files of the specified types. See "Writing a File Filter Function" for a description of the file filter function.

ASSEMBLY-LANGUAGE INFORMATION

The trap macro and routine selector for StandardGetFile are

Trap macro

Selector

_Pack3

$0006

SPECIAL CONSIDERATIONS

The StandardGetFile procedure is not available in all versions of system software. Use the Gestalt function to determine whether StandardGetFile is available before calling it.

Because StandardGetFile may move memory, you should not call it at interrupt time.

CustomGetFile

Call the CustomGetFile procedure when your application requires more control over the Open dialog box than is possible using StandardGetFile .

PROCEDURE CustomGetFile (fileFilter: FileFilterYDProcPtr;
                                         numTypes: Integer;
                                         typeList: SFTypeList;
                                         VAR reply: StandardFileReply;
                                         dlgID: Integer;
                                         where: Point;
                                         dlgHook: DlgHookYDProcPtr;
                                         filterProc: ModalFilterYDProcPtr;
                                         activeList: Ptr;
                                         activateProc: ActivateYDProcPtr;
                                         yourDataPtr: UNIV Ptr);
fileFilter
A pointer to an optional file filter function, provided by your application, through which CustomGetFile passes files of the specified types.
numTypes
The number of file types to be displayed. If you specify a numTypes value of -1, the first filtering passes files of all types.
typeList
A list of file types to be displayed.
reply
The reply record, which CustomGetFile fills in before returning.
dlgID
The resource ID of a customized dialog template. To use the standard template, set this parameter to 0.
where
The upper-left corner of the dialog box in global coordinates. If you specify the point (-1,-1), CustomGetFile automatically centers the dialog box on the screen.
dlgHook
A pointer to your dialog hook function, which handles item selections received from the Dialog Manager. Specify a value of NIL if you have not added any items to the dialog box and want the standard items handled in the standard ways. See "Writing a Dialog Hook Function" for a description of the dialog hook function.
filterProc
A pointer to your modal-dialog filter function, which determines how ModalDialog filters events when called by CustomGetFile . Specify a value of NIL if you are not supplying your own function. See "Writing a Modal-Dialog Filter Function" for a description of the modal-dialog filter function.
activeList
A pointer to a list of all dialog items that can be activated--that is, made the target of keyboard input. The list is stored as an array of 16-bit integers. The first integer is the number of items in the list. The remaining integers are the item numbers of all possible keyboard targets, in the order that they are activated by the Tab key. If you supply an activeList parameter of NIL , CustomGetFile directs all keyboard input to the displayed list.
activateProc
A pointer to your activation procedure, which controls the highlighting of dialog items that are defined by your application and that can receive keyboard input. See "Writing an Activation Procedure" for a description of the activation procedure.
yourDataPtr
A pointer to optional data supplied by your application. When CustomGetFile calls any of your callback routines, it pushes this parameter on the stack, making the data available to your callback routines. If you are not supplying any data of your own, specify a value of NIL .

DESCRIPTION

The CustomGetFile procedure is an alternative to StandardGetFile when you want to use a customized dialog box or handle the default Open dialog box in a customized way. CustomGetFile presents a dialog box through which the user specifies the name and location of a file to be opened. While the dialog box is active, CustomGetFile gets and handles events until the user completes the interaction, either by selecting a file to open or by canceling the operation. CustomGetFile returns the user's input in a record of type StandardFileReply .

The first four parameters are similar to the same parameters in StandardGetFile . The fileFilter , numTypes , and typeList parameters determine which files appear in the list of choices. If you specify a value of -1 in the numTypes parameter, CustomGetFile displays or passes to your file filter function all files and folders (not just the files) at the current level of the display hierarchy. If you provide a filter function, CustomGetFile passes it both the pointer to the catalog entry for each file to be processed and also a pointer to the optional data passed by your application in its call to CustomGetFile .

ASSEMBLY-LANGUAGE INFORMATION

The trap macro and routine selector for CustomGetFile are

Trap macro

Selector

_Pack3

$0008

SPECIAL CONSIDERATIONS

The CustomGetFile procedure is not available in all versions of system software. Use the Gestalt function to determine whether CustomGetFile is available before calling it.

Because CustomGetFile may move memory, you should not call it at interrupt time.

SFGetFile

Use the SFGetFile procedure to display the default Open dialog box when the user is opening a file.

PROCEDURE SFGetFile (where: Point; prompt: Str255;
                                         fileFilter: FileFilterProcPtr;
                                         numTypes: Integer; typeList: SFTypeList;
                                         dlgHook: DlgHookProcPtr; VAR reply: SFReply);
where
The upper-left corner of the dialog box, in global coordinates.
prompt
Ignored.
fileFilter
A pointer to an optional file filter function, provided by your application, through which SFGetFile passes files of the specified types.
numTypes
The number of file types to be displayed. If you specify a numTypes value of -1, the first filtering passes files of all types.
typeList
A list of file types to be displayed.
dlgHook
A pointer to your dialog hook function, which handles item selections received from the Dialog Manager. Specify a value of NIL if you want the standard items handled in the standard ways.
reply
The reply record, which SFGetFile fills in before returning.

DESCRIPTION

The SFGetFile procedure displays a dialog box listing the names of a specific group of files from which the user can select one to be opened (as during an Open menu command). During the dialog, SFGetFile gets and handles events (possibly with the assistance of application-defined callback routines) until the user completes the interaction, either by selecting a file to open or by canceling the open operation. SFGetFile returns the user's input in a record of type SFReply .

ASSEMBLY-LANGUAGE INFORMATION

The trap macro and routine selector for SFGetFile are

Trap macro

Selector

_Pack3

$0002

SPECIAL CONSIDERATIONS

Because SFGetFile may move memory, you should not call it at interrupt time.

SFPGetFile

Call the SFPGetFile procedure when your application requires more control over the Open dialog box than is possible using SFGetFile .

PROCEDURE SFPGetFile (where: Point; prompt: Str255;
                                         fileFilter: FileFilterProcPtr;
                                         numTypes: Integer; typeList: SFTypeList;
                                         dlgHook: DlgHookProcPtr;
                                         VAR reply: SFReply; dlgID: Integer;
                                         filterProc: ModalFilterProcPtr);
where
The upper-left corner of the dialog box, in global coordinates.
prompt
Ignored.
fileFilter
A pointer to an optional file filter function, provided by your application, through which SFPGetFile passes files of the specified types.
numTypes
The number of file types to be displayed. If you specify a numTypes value of -1, the first filtering passes files of all types.
typeList
A list of file types to be displayed.
dlgHook
A pointer to your dialog hook function, which handles item selections received from the Dialog Manager. Specify a value of NIL if you have not added any items to the dialog box and want the standard items handled in the standard ways.
reply
The reply record, which SFPGetFile fills in before returning.
dlgID
The resource ID of a customized dialog template.
filterProc
A pointer to your modal-dialog filter function, which determines how the ModalDialog procedure filters events when called by the SFPGetFile procedure. Specify a value of NIL if you are not supplying your own function.

DESCRIPTION

The SFPGetFile procedure is an alternative to SFGetFile when you want to display a customized Open dialog box or handle the default dialog box in a customized way. During the dialog, SFPGetFile gets and handles events (possibly with the assistance of application-defined callback routines) until the user completes the interaction, either by selecting a file to open or by canceling the open operation. SFPGetFile returns the user's input in a record of type SFReply .

ASSEMBLY-LANGUAGE INFORMATION

The trap macro and routine selector for SFPGetFile are

Trap macro

Selector

_Pack3

$0004

SPECIAL CONSIDERATIONS

Because SFPGetFile may move memory, you should not call it at interrupt time.


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next